﻿'
' * <p>Description: Manager for TeleComSystem</p>
' * <p>@version 1.0.0</p>
' * <p>Modification: (Date-Version-Author-Description)</p>
' * <p>----------------------------------------------------------------------</p>
' * <p>2005.08.10/1.0.0@ Zorlo Wang   - Create class .</p>
' 


Imports System.Data
Imports System.Web.UI
Imports System.Collections
Imports com.auo.Sa.Net.Library.Components
' *** using  ComponentFactory
Imports com.auo.Sa.Net.Library.Components.Data
' *** using  DbSession
Imports com.auo.Sa.Net.Common.Library.Components
' *** using  TransManagerBase
Imports com.auo.Telecom.Form.Library.Components.Entity
' *** using  EntityClass
Imports com.auo.flower.remote
' *** using com.auo.flower.remote;

Namespace MVPN.Manager
    ''' <summary>
    ''' tele_manager 的摘要说明。
    ''' </summary>
    Public Class FromMVPNRemote
        Inherits TransManagerBase
        Protected objhelper As IRemotingFlowHelper = DirectCast(RemotingHelperCreator.CreateInstance(GetType(IRemotingFlowHelper)), IRemotingFlowHelper)
        Protected FormKind As String = "AUO.FORM.439"

        ''' <summary>
        ''' 初始化Page属性
        ''' </summary>
        ''' <param name="page">调用者Web Page</param>
        Public Sub New(ByVal page As Page)
            MyBase.New(page)
        End Sub


#Region "createform"
        ''' <summary>
        ''' 创建一个新表
        ''' </summary>
        ''' <param name="formfiller">填表人</param>
        ''' <returns>结果集form_no穿件的表单号</returns>
        Public Function createform(ByVal formfiller As String) As Integer
            Try
                Dim formNo As Integer = objhelper.CreateNewForm(FormKind, formfiller)
                Return formNo
            Catch ex As Exception
                Throw New Exception(ex.ToString())
            End Try
        End Function
#End Region

#Region "active"
        ''' <summary>
        ''' 更新数据资料UpdataForm
        ''' </summary>
        ''' <param name="formNo">表单号</param>
        ''' <returns>结果集是否成功</returns>
        Public Function active(ByVal formNo As Integer) As Boolean
            Try
                Dim activestate As Boolean = objhelper.ActiveForm(FormKind, formNo)
                Return activestate
            Catch ex As Exception
                Throw New Exception(ex.ToString())
            End Try
        End Function
#End Region

#Region "send"
        ''' <summary>
        ''' 送签(Insert数据库)
        ''' </summary>
        ''' <param name="formNo">表单编号</param>
        ''' <param name="apply">Insert数据集</param>
        ''' <returns>结果集是否成功</returns>
        Public Function send(ByVal formNo As Integer, ByVal apply As String) As Boolean
            Try
                Dim sendstate As Boolean = objhelper.SendForm(FormKind, formNo, apply)
                Return sendstate
            Catch ex As Exception
                Throw New Exception(ex.ToString())
            End Try
        End Function
#End Region

#Region "AddFlag"
        ''' <summary>
        ''' 把数据传递到数据库中,更新数据库
        ''' </summary>
        ''' <param name="formNo">表单编号</param>
        ''' <param name="type">申请类别</param>
        ''' <param name="createdDate">申请时间</param>
        ''' <param name="userName">使用者姓名</param>
        ''' <param name="userDept">使用者部门</param>
        ''' <param name="userSite">使用者厂区</param>
        ''' <param name="applyType">申请类型</param>
        ''' <param name="moveType">异动类型</param>
        ''' <param name="rightType">权限种类</param>
        ''' <param name="Reason">申请原因</param>
        Public Sub AddFlag(ByVal formNo As Integer, ByVal type As String, ByVal createdDate As String, ByVal userNo As String, ByVal userName As String, ByVal userDept As String, _
         ByVal userSite As String, ByVal applyType As String, ByVal moveType As String, ByVal rightType As String, ByVal Reason As String)
            Try
                Dim objParas As IParameter() = New IParameter(9) {}
                objParas(0) = New para("type", type)
                objParas(1) = New para("created_date", createdDate)
                objParas(2) = New para("user_no", userNo)
                objParas(3) = New para("user_name", userName)
                objParas(4) = New para("user_dept", userDept)
                objParas(5) = New para("user_site", userSite)
                objParas(6) = New para("applytype", applyType)
                objParas(7) = New para("movetype", moveType)
                objParas(8) = New para("auth", rightType)
                objParas(9) = New para("reason", Reason)
                objhelper.AddFlag(FormKind, formNo, objParas)
            Catch ex As Exception
                Throw New Exception("AddFlag Appear Abnormity,and Failed!!", ex)
            End Try
        End Sub
#End Region

#Region "SaveFormStatus"
        ''' <summary>
        ''' 更新签核的结果
        ''' </summary>
        ''' <param name="maintainNo">维修表单编号</param>
        ''' <param name="status">签核状况</param>
        ''' <returns>结果集bool</returns>
        Public Function SaveFormStatus(ByVal maintainNo As Integer, ByVal status As String) As Boolean
            Try
                Dim tm As teleMaintain = teleMaintain.GetInstance(Me.DbSession, maintainNo, True)
                tm.Status = status
                tm.Update()
                Return True
            Catch
                Return False
            End Try
        End Function
#End Region

#Region "isWithDrawStatus"
        ''' <summary>
        ''' 返回表单现在的签核状态是否符合撤回条件
        ''' </summary>
        ''' <param name="maintainNo">维修表单编号</param>
        ''' <returns>结果集bool</returns>
        Public Function isWithDrawStatus(ByVal maintainNo As Integer) As Boolean
            Dim dtStatus As DataTable = teleMaintain.FetchStatus(Me.DbSession, maintainNo)
            '如果返回的资料不为空的话,返回Status栏位值
            If dtStatus.Rows.Count > 0 Then
                Dim status As String = dtStatus.Rows(0)(0).ToString().Trim()
                '				string status = dtStatus.Rows[0][0].ToString();
                If dtStatus.Rows(0)(0).ToString().Trim().Equals("0") OrElse dtStatus.Rows(0)(0).ToString().Trim().Equals("R") OrElse dtStatus.Rows(0)(0).ToString().Trim().Equals("W") Then
                    Return True
                End If
            End If
            Return False
        End Function
#End Region

#Region "isOverBoss"
        ''' <summary>
        ''' 返回是否是副总级BOSS
        ''' </summary>
        ''' <param name="EmpNo">员工编号</param>
        ''' <returns>结果集bool</returns>
        Public Function isOverBoss(ByVal EmpNo As String) As Boolean
            Dim dtBossLevel As DataTable = teleMaintain.FetchEmpLevel(Me.DbSession, EmpNo)
            If dtBossLevel.Rows.Count > 0 Then
                If Convert.ToInt32(dtBossLevel.Rows(0)(0).ToString()) < 6 Then
                    Return True
                End If
            End If
            Return False
        End Function
#End Region

#Region "FetchFlowER"
        ''' <summary>
        ''' 按maintainNo查找flower签核页面相关的信息
        ''' </summary>
        ''' <param name="maintainNo">电信表单号</param>
        ''' <returns>结果集DataTable</returns>
        Public Function FetchFlowER(ByVal maintainNo As String) As DataTable
            Return teleMaintain.FetchFlowER(Me.DbSession, maintainNo)
        End Function
#End Region

#Region "deleteform"
        ''' <summary>
        ''' 删除非国际的表单
        ''' </summary>
        ''' <param name="formKind"></param>
        ''' <param name="formNo"></param>
        ''' <param name="formAcator"></param>
        Public Function deleteform(ByVal formKind As String, ByVal formNo As Integer, ByVal formAcator As String) As Boolean

            Dim isdelete As Boolean
            Try
                isdelete = objhelper.DeleteForm(formKind, formNo, formAcator)
            Catch ex As Exception
                Throw New Exception(ex.ToString())
            End Try
            Return isdelete
        End Function
#End Region
        '''*********************ADD BY CHERRYTAN***********************
#Region "RecallForm"
        ''' <summary>
        ''' 撤回表单
        ''' </summary>
        ''' <param name="FormKind"></param>
        ''' <param name="FormNo"></param>
        ''' <param name="opretion"></param>
        ''' <returns></returns>
        Public Function RecallForm(ByVal FormKind As String, ByVal FormNo As Integer, ByVal opretion As String) As Boolean

            Dim update As Boolean
            Try
                update = objhelper.RecallForm(FormKind, FormNo, opretion)
                Return True
            Catch
                Return False
            End Try
        End Function

#End Region
        '''*********************ADD BY CHERRYTAN***********************




    End Class
End Namespace
